package com.pass.seven;

import org.apache.hadoop.conf.Configured;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
import org.apache.hadoop.util.Tool;

/**
 * Pass Seven:
 * 
 * for q4.
 * 
 * calculate sum (connected component node # ^2 ) / # of nodes.
 * 
 * this is the first pass.
 * 
 * @author bh349
 */
public class PassSeven extends Configured implements Tool {

	public int run(String[] args) throws Exception {
		Job job = new Job(getConf(), "pass 7");
		job.setJarByClass(PassSeven.class);
		job.setMapperClass(PassSevenMapper.class);
		job.setReducerClass(PassSevenReducer.class);
		job.setOutputKeyClass(Text.class);
		job.setOutputValueClass(IntWritable.class);
		FileInputFormat.addInputPaths(job, "pass3out");
		FileOutputFormat.setOutputPath(job, new Path("pass7out"));
		return job.waitForCompletion(true) ? 0 : 1;
	}
}
